from rest_framework import serializers
from goods.models import *


class SPUGoodsSerializer(serializers.ModelSerializer):
    """展示所有商品"""
    category1_id = serializers.IntegerField()
    category2_id = serializers.IntegerField()
    category3_id = serializers.IntegerField()
    brand = serializers.StringRelatedField()
    brand_id = serializers.IntegerField()

    class Meta:
        model = SPU
        exclude = ['category1', 'category2', 'category3']


class SPUBrandsSerizliser(serializers.ModelSerializer):
    """品牌"""
    class Meta:
        model = Brand
        fields = '__all__'


class CategorysSerizliser(serializers.ModelSerializer):
    """一级分类"""
    class Meta:
        model = GoodsCategory
        fields = ['id', 'name']
